/*
 * @Author: your name
 * @Date: 2021-01-29 15:52:42
 * @LastEditTime: 2021-01-29 17:45:49
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /ydk-taro/rollup.config.js
 */
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import scss from 'rollup-plugin-scss';
import RollupJson from '@rollup/plugin-json';
import { terser } from "rollup-plugin-terser";
import { babel } from '@rollup/plugin-babel';

const path = require('path');
const getPath = _path => path.resolve(__dirname, _path);

export default {
    input: getPath('./src/components/index.ts'),
    output: [
        {
            file: getPath('./dist/index.js'),
            format: 'cjs',
            sourcemap: false 
        },
        {
            file: getPath('./dist/index.esm.js'),
            format: 'es',
        }
    ],
    external: [
        "react",
        "react-dom",
        "@tarojs/components",
        "@tarojs/runtime",
        "@tarojs/taro",
        "@tarojs/react",
        "dayjs",
        "js-md5",
        "crypto-js"
    ],
    treeshake: true,
    plugins: [
        scss({
            output: getPath('./dist/style/index.scss')
        }),
        resolve(),
        commonjs(),
        RollupJson(),
        typescript({
            tsConfig: getPath('./tsconfig.rollup.json'),
        }),
        babel({
            exclude: 'node_modules/**'
        }),
        terser()
    ]
}